<template>
    <div class="gesture">
        <p class="reset" @tap="resetPwd">重置密码</p>
        <p class="title">{{title}}</p>
        <canvas canvas-id="canvasLock" class="mycanvas" @touchend="onTouchend"
        @touchstart="onTouchstart" @touchmove="onTouchmove"></canvas>
    </div>
</template>

<script>
import tools from 'common/js/tools'
import Lock from 'common/js/lock'
export default {
  name: 'Gesture',
  data () {
    return {
      title: '绘制解锁图案'
    }
  },
  onLoad () {
    const that = this
    that.lock = new Lock(that, {
      width: 300,
      height: 300,
      chooseType: 3,
      id: 'canvasLock'
    })
  },
  methods: {
    resetPwd () {
      this.lock.updatePassword()
    },
    trigger (str) {
      this.title = str
    },
    toIndex () {
      tools.showToast('解锁成功~')
      setTimeout(() => {
        wx.navigateBack({
          delta: 1
        })
      }, 2000)
    }
  }
}
</script>

<style lang="stylus" scoped>
.gesture
    height 100%
.reset {
    color: #22C3AA;
    font-size: 24rpx;
    text-align: right;
    padding: 30rpx 20rpx;
}
.title {
    text-align: center;
    color: #22C3AA;
}
.mycanvas {
    width: 600rpx;
    height: 600rpx;
    margin: 100rpx auto;
}
</style>
